import request from '@/utils/request'


/**
 * 增加角色信息
 * @param {Object} data
 */
export function addRoleInfo(data) {
	console.log(data)
	return request({
		url: '/admin/v1/role/',
		method: 'post',
		data
	})
}

/**
 * 修改角色信息
 * @param {Object} data
 */
export function modifyRoleInfo(data) {
	return request({
		url: `/admin/v1/role/${data.roleId}`,
		method: 'put',
		data
	})
}

/**
 * 通过角色Id获取角色菜单
 * @param {Object} roleId
 */
export function getRolePermissionsByRoleId(roleId) {
	return request({
		url: `/admin/v1/role/${roleId}/menus`,
		method: 'get',
	})
}

/**
 * 获取所有菜单信息
 */
export function getRoleMenusAll() {
	return request({
		url: '/admin/v1/role/menus/tree/all',
		method: 'get'
	})
}

/**
 * 删除角色信息
 */
export function deleteRoleInfo(roleId) {
	return request({
		url: `/admin/v1/role/${roleId}`,
		method: 'delete'
	})
}


/**
 * 分页获取角色信息
 * @param {Object} data
 */
export function getRoleListByPage(data) {
	return request({
		url: `/admin/v1/role/${data.page}/${data.size}`,
		method: 'get'
	})
}

/**
 * 搜索角色
 * @param {Object} data
 */
export function searchRoleList(data) {
	return request({
		url: `/admin/v1/role/search`,
		method: 'post',
		data
	})
}
